#include <cstdio>
#include <algorithm>

//TODO:
const int N = 1000010;
int n, sum, a[N], vis[11], ans;

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
	freopen("testdata.in", "r", stdin);
	freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
	freopen("T2.in", "r", stdin);
	freopen("T2.out", "w", stdout);
#endif
#endif

	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		sum += a[i];
		++vis[a[i]];
	}
	for (int i = 1; i < 11; ++i) {
		if (!vis[i]) continue;
		--vis[i];
		for (int j = 1; j < 11; ++j) {
			if (!vis[j]) continue;
			if ((sum - i - j) % 10 == 0) ans = std::max(ans,((i + j) % 10 ? ((i + j) % 10) : 10));
		}
		++vis[i];
	}
	printf("%d", ans);
	return 0;
}